package weifei.live.simulation.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import weifei.live.simulation.entity.Sort;
import weifei.web.Result;

@RestController
@RequestMapping("/adminer")
public class SortAdminerController
{
    @Autowired
    private Sort dao_sort;

    @PostMapping("/addSort")
    public Result addSort(@RequestParam("name") String name)
    {
        if (name == null)
            return Result.exception("参数错误");

        if (!new Sort(name).insert())
            return Result.exception("添加分类失败，数据库出错");
        return Result.success("添加分类 “" + name + "” 成功");
    }
}


